<?php
session_start();
include('fungsi_admin.php');
if (!empty($_SESSION['user'])){
?>
<html>
	<head>
		<title>BudiNews.com</title>
		<link rel="shortcut icon" href="../admin/css/mos-css/img/quote.png">
		<!-- Pemanggilan gambar favicon-->
		<link rel="stylesheet" type="text/css" href="../admin/css/mos-css/mos-style.css">
		<!--pemanggilan file css-->
	</head>
	<body>
		<div id="header">
			<div class="inHeader">
				<div class="mosAdmin">
					selamat datang di halaman Admin BudiNews.com
					<br/>
					<a href="keluar.php">Keluar</a>
				</div>
				<div class="clear">
				</div>
			</div>
		</div>
		<div id="wrapper">
			<div id="leftBar">
				<ul>
					<li>
						<a href="dashboard.php">Berita</a>
					</li>
					<li>
						<a href="kategori_tampil.php">Kategori</a>
					</li>
					<li>
						<a href="keluar.php">Keluar</a>
					</li>
				</ul>
			</div>
			<div id="rightContent">
				<h3>Halaman Edit Berita</h3>
				<center>
					<form action="" method="post" enctype="multipart/form-data">
						<table>
							<tbody>
								<tr>
									<td>
									<b>Judul Berita</b>
									</td>
									<td>
									<input type="text" name="judul">
									</td>
								</tr>
								<tr>
									<td>
									<b>Isi Berita</b>
									</td>
									<td>
									<textarea cols="30" rows="20" name="detail">
									</textarea>
									</td>
								</tr>
								<tr>
									<td>
									<b>Kategori</b>
									</td>
									<td>
									<select name="kategori">
	<option value="-">Pilih Kategori</option>
	<?php
		kategori();
	?>
</select>
									</td>
								</tr>
								<tr>
									<td>
									<b>Status</b>
									</td>
									<td>
									<select name="status">
	<option value="-">Pilih Status</option>
	<option value="1">headline</option>
	<option value="2">feature</option>
	<option value="3">biasa</option>
</select>
									</td>
								</tr>
								<tr>
									<td>
									<b>Gambar Berita</b>
									</td>
									<td>
									<input type="file" name="gambar">
									</td>
								</tr>
								<tr>
									<td>
									</td>
									<td>
									<input type="submit" value="POST">
									</td>
								</tr>
							</tbody>
						</table>
					</form>
				</center>
			</div>
			<div class="clear">
			</div>
			<div id="footer">
				&copy; 2014 Created by |
				<a href="../pwl">BudiNews.com</a>
			</div>
		</div>
	</body>
</html>
<?php
if(!empty($_POST)){

	$order   = array("\"", "\'");
	$replace = '&#34;';
	$ber = str_replace($order, $replace, $_POST['detail']);
	
	move_uploaded_file($_FILES['gambar']['tmp_name'],"../gambar/".$_FILES['gambar']['name']);
	$masuk = tambah($_POST['judul'],trim($ber),$_FILES['gambar']['name'],$_POST['kategori'],$_POST['status']);
}
}else{
echo "anda tidak berhak";
}
?>